var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var app = express();
var bodyParser = require('body-parser');
var util = require('util');
var signServletAgent = require('./servers/getSignServletAgent.js');
var vCodeAgent = require('./servers/verficationCodeAgent.js');
var getNumServletAgent = require('./servers/getNumServletAgent.js');
var youtouAgent = require('./servers/youtuServletAgent.js');
var hengFengAgent = require('./servers/hengFengAgent.js');
var kexinBarbrecordAgent = require('./servers/kexinbadrecordAgent.js');
var kexinBrokenAgent = require('./servers/kexinBrokenAgent.js');
var dataAgent = require('./servers/getDateAgent.js');
var smsSeverAgent = require('./servers/sendSMSServletAgent.js');
var configAgent = require('./servers/getConfigAgent.js');
var monidata = require('./servers/monidata.js');

// 创建 application/x-www-form-urlencoded 编码解析
var urlencodedParser = bodyParser.urlencoded({
    extended: false
});
app.use(cookieParser());

app.use(session({
    secret: '12345',
    name: 'sessionID', //这里的name值得是cookie的name，默认cookie的name是：connect.sid
    cookie: "2342312324423", //设置maxAge是80000ms，即80s后session和相应的cookie失效过期
    resave: false,
    saveUninitialized: true,
}));
app.get('/', function(req, res) {
    res.send('Hello World');
});

app.get('/dist/index.html', function(req, res) {
    res.sendFile(__dirname + "/dist/index.html");
});
app.get('/dist/index2.html', function(req, res) {
    res.sendFile(__dirname + "/dist/index2.html");
});

app.get('/dist/home.html', function(req, res) {
    res.sendFile(__dirname + "/dist/home.html");
});

app.get('/dist/sign_in.html', function(req, res) {
    res.sendFile(__dirname + "/dist/sign_in.html");
});


app.get('/dist/js/jquery/jquery-1.11.1.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/jquery/jquery-1.11.1.min.js");
});
app.get('/dist/js/plugins/jquery.cookie.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/jquery.cookie.js");
});

app.get('/dist/js/jquery/jquery-migrate.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/jquery/jquery-migrate.min.js");
});
app.get('/dist/js/jquery/jquery-migrate.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/jquery/jquery-migrate.min.js");
});
app.get('/dist/js/plugins/mobile_events/jquery.mobile-events.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/mobile_events/jquery.mobile-events.min.js");
});

app.get('/dist/js/plugins/mobile_events/jquery.mobile-events.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/mobile_events/jquery.mobile-events.min.js");
});
app.get('/dist/js/jquery_ui/jquery-ui.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/jquery_ui/jquery-ui.min.js");
});
app.get('/dist/js/bootstrap/bootstrap.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/bootstrap/bootstrap.min.js");
});

app.get('/dist/js/plugins/flot/excanvas.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/flot/excanvas.js");
});
app.get('/dist/js/plugins/sparklines/jquery.sparkline.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/sparklines/jquery.sparkline.min.js");
});
app.get('/dist/js/plugins/flot/flot.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/flot/flot.min.js");
});
app.get('/dist/js/plugins/datatables/jquery.dataTables.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/datatables/jquery.dataTables.min.js");
});
app.get('/dist/js/plugins/flot/flot.resize.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/flot/flot.resize.js");
});
app.get('/dist/js/plugins/flot/flot.pie.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/flot/flot.pie.js");
});
app.get('/dist/js/plugins/bootstrap_switch/bootstrapSwitch.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/bootstrap_switch/bootstrapSwitch.min.js");
});
app.get('/dist/js/plugins/fullcalendar/fullcalendar.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/fullcalendar/fullcalendar.min.js");
});
app.get('/dist/js/plugins/common/wysihtml5.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/common/wysihtml5.min.js");
});
app.get('/dist/js/plugins/datatables/jquery.dataTables.columnFilter.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/datatables/jquery.dataTables.columnFilter.js");
});
app.get('/dist/js/plugins/common/bootstrap-wysihtml5.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/common/bootstrap-wysihtml5.js");
});
app.get('/dist/js/plugins/select2/select2.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/select2/select2.js");
});
app.get('/dist/js/plugins/bootstrap_colorpicker/bootstrap-colorpicker.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/bootstrap_colorpicker/bootstrap-colorpicker.min.js");
});
app.get('/dist/js/plugins/mention/mention.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/mention/mention.min.js");
});
app.get('/dist/js/plugins/input_mask/bootstrap-inputmask.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/input_mask/bootstrap-inputmask.min.js");
});
app.get('/dist/js/plugins/fileupload/load-image.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/fileupload/load-image.min.js");
});
app.get('/dist/js/plugins/fileinput/bootstrap-fileinput.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/fileinput/bootstrap-fileinput.js");
});
app.get('/dist/js/plugins/modernizr/modernizr.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/modernizr/modernizr.min.js");
});
app.get('/dist/js/plugins/retina/retina.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/retina/retina.js");
});
app.get('/dist/js/plugins/respond.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/respond.js");
});
app.get('/dist/js/plugins/spin.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/spin.js");
});
app.get('/dist/js/plugins/bootstrap_datetimepicker/bootstrap-datetimepicker.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/bootstrap_datetimepicker/bootstrap-datetimepicker.js");
});
app.get('/dist/js/plugins/Validform_v5.3.2_min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/Validform_v5.3.2_min.js");
});



app.get('/dist/js/html5shiv.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/html5shiv.js");
});

app.get('/dist/js/project/urlValue.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/project/urlValue.js");
});

app.get('/dist/js/project/singIn.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/project/singIn.js");
});
app.get('/dist/js/plugins/html5shiv.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/html5shiv.min.js");
});
app.get('/dist/js/plugins/bootstrap_hover_dropdown/twitter-bootstrap-hover-dropdown.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/plugins/bootstrap_hover_dropdown/twitter-bootstrap-hover-dropdown.min.js");
});
app.get('/dist/js/bootstrap/dropdown.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/bootstrap/dropdown.js");
});

app.get('/dist/js/project/singIn.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/project/singIn.min.js");
});
app.get('/dist/js/project/home.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/project/home.min.js");
});
app.get('/dist/js/project/echarts.min.js', function(req, res) {
    res.sendFile(__dirname + "/dist/js/project/echarts.min.js");
});


app.get('/dist/css/main.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/main.css");
});
app.get('/dist/css/signin.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/signin.css");
});

app.get('/dist/css/plugins.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/plugins.css");
});
app.get('/dist/css/bootstrap.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/bootstrap.css");
});

app.get('/dist/css/demo.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/demo.css");
});
app.get('/dist/css/aie8.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/aie8.css");
});
app.get('/dist/css/validform.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/validform.css");
});
app.get('/dist/css/light-theme.css', function(req, res) {
    res.sendFile(__dirname + "/dist/css/light-theme.css");
});


app.get('/dist/fonts/fontawesome-webfont.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/fontawesome-webfont.eot");
});
app.get('/dist/fonts/fontawesome-webfont.ttf', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/fontawesome-webfont.ttf");
});
app.get('/dist/fonts/fontawesome-webfont.woff', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/fontawesome-webfont.woff");
});
app.get('/dist/fonts/fontawesome-webfont_2d2816fe.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/fontawesome-webfont_2d2816fe.eot");
});
app.get('/dist/fonts/montserrat-bold-webfont.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-bold-webfont.eot");
});
app.get('/dist/fonts/montserrat-bold-webfont.svg', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-bold-webfont.svg");
});
app.get('/dist/fonts/montserrat-bold-webfont.ttf', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-bold-webfont.ttf");
});
app.get('/dist/fonts/montserrat-bold-webfont.woff', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-bold-webfont.woff");
});
app.get('/dist/fonts/montserrat-bold-webfont_2d2816fe.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-bold-webfont_2d2816fe.eot");
});
app.get('/dist/fonts/montserrat-regular-webfont.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-regular-webfont.eot");
});
app.get('/dist/fonts/montserrat-regular-webfont.svg', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-regular-webfont.svg");
});
app.get('/dist/fonts/montserrat-regular-webfont.ttf', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-regular-webfont.ttf");
});
app.get('/dist/fonts/montserrat-regular-webfont.woff', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-regular-webfont.woff");
});
app.get('/dist/fonts/montserrat-regular-webfont_2d2816fe.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/montserrat-regular-webfont_2d2816fe.eot");
});
app.get('/dist/fonts/bootstrap/glyphicons-halflings-regular.woff', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/bootstrap/glyphicons-halflings-regular.woff");
});
app.get('/dist/fonts/bootstrap/glyphicons-halflings-regular.ttf', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/bootstrap/glyphicons-halflings-regular.ttf");
});
app.get('/dist/fonts/bootstrap/glyphicons-halflings-regular.eot', function(req, res) {
    res.sendFile(__dirname + "/dist/fonts/bootstrap/glyphicons-halflings-regular.eot");
});


app.get('/dist/img/creditLoan/shoukuankahao_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/creditLoan/shoukuankahao_icon.png");
});
app.get('/dist/img/header_bg2.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/header_bg2.jpg");
});
app.get('/dist/img/logo.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/img/logo.gif");
});
app.get('/dist/img/loding.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/img/loding.gif");
});

app.get('/dist/img/logo.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/logo.png");
});
app.get('/dist/img/logo2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/logo2.png");
});
app.get('/dist/img/banner_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/banner_icon.png");
});
app.get('/dist/img/shenfenyanzheng_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/shenfenyanzheng_icon.png");
});
app.get('/dist/img/datubiao1_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/datubiao1_icon.png");
});
app.get('/dist/img/fanqizha_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/fanqizha_icon.png");
});
app.get('/dist/img/datubiao2_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/datubiao2_icon.png");
});
app.get('/dist/img/yizhi_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/yizhi_icon.png");
});
app.get('/dist/img/buyizhi_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/buyizhi_icon.png");
});
app.get('/dist/img/meiyoubuliang_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/meiyoubuliang_icon.png");
});
app.get('/dist/img/wanjiantongpingfen_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/wanjiantongpingfen_icon.png");
});
app.get('/dist/img/pingfenshuju_ico.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/pingfenshuju_ico.png");
});
app.get('/dist/img/0_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/0_icon.png");
});
app.get('/dist/img/500_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/500_icon.png");
});
app.get('/dist/img/600_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/600_icon.png");
});
app.get('/dist/img/700_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/700_icon.png");
});
app.get('/dist/img/800_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/800_icon.png");
});
app.get('/dist/img/1000_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/1000_icon.png");
});
app.get('/dist/img/biaochi_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/biaochi_icon.png");
});
app.get('/dist/img/jiaocha_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/jiaocha_icon.png");
});
app.get('/dist/img/jiaocha_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/jiaocha_icon2.png");
});
app.get('/dist/img/lianghao_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/lianghao_icon.png");
});

app.get('/dist/img/lianghao_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/lianghao_icon2.png");
});
app.get('/dist/img/jihao_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/jihao_icon.png");
});

app.get('/dist/img/jihao_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/jihao_icon2.png");
});
app.get('/dist/img/youxiu_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/youxiu_icon.png");
});
app.get('/dist/img/youxiu_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/youxiu_icon2.png");
});
app.get('/dist/img/yiban_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/yiban_icon.png");
});
app.get('/dist/img/yiban_icon2.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/yiban_icon2.png");
});
app.get('/dist/img/buliangxinxi_icon.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/buliangxinxi_icon.png");
});








app.get('/dist/img/btn1_bg.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/btn1_bg.jpg");
});
app.get('/dist/img/nav-bgs.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/nav-bgs.jpg");
});
app.get('/dist/img/ierl.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/ierl.png");
});
app.get('/dist/img/arrow1.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/img/arrow1.gif");
});
app.get('/dist/img/arrow2.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/img/arrow2.gif");
});
app.get('/dist/img/error.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/error.png");
});
app.get('/dist/img/right.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/right.png");
});
app.get('/dist/img/rlsb.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/rlsb.jpg");
});
app.get('/dist/img/fqz.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/fqz.jpg");
});
app.get('/dist/img/dsj.png', function(req, res) {
    res.sendFile(__dirname + "/dist/img/dsj.png");
});
app.get('/dist/img/dsj.jpg', function(req, res) {
    res.sendFile(__dirname + "/dist/img/dsj.jpg");
});
app.get('/dist/img/timg.gif', function(req, res) {
    res.sendFile(__dirname + "/dist/img/timg.gif");
});


app.post('/wjttest/login/in', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({
        "path": "/wjttestlogin/in"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var singInData = monidata.getSingInData(req.body);
    console.log(JSON.stringify(singInData));
    res.end(JSON.stringify(singInData));
});

app.post('/wjttest/pkg/log/page', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var queryRecord = monidata.getQueryRecordServlet(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});
app.post('/wjttest/pkg/log/detail', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
//    var queryRecord = monidata.getAccountsDetails(req.body);
    var queryRecord = monidata.getDetails2(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});


app.post('/wjttest/user/uppwd', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var queryRecord = monidata.getQueryRecordServlet(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});

app.post('/wjttest/mer/manag/pwd', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({path:"/wjttest/mer/manag/pwd"}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var queryRecord = monidata.getQueryRecordServlet(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});

app.post('/wjttest/appraisal/accountsDetailsServlet', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var queryRecord = monidata.getAccountsDetails(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});

app.post('/wjttest/mer/manag/index', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var queryRecord = monidata.getUsers(req.body);
    console.log(JSON.stringify(queryRecord));
    res.end(JSON.stringify(queryRecord));
});
app.post('/wjttest/score/index', urlencodedParser, function(req, res) {
    /*    res.writeHead(200, {
            'Content-Type': 'text/html;charset=utf-8'
        }); //设置response编码为utf-8*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        // res.end(data);
    });
    agentObjet.request();
    var sindex = monidata.getScoreIndex(req.body);
    console.log(JSON.stringify(sindex));
    res.end(JSON.stringify(sindex));
});

var sessions = {};
var key = "session_id";
var EXPIRES = 20 * 60 * 1000;
var generate = function() {
    var session = {};
    session.id = (new Date()).getTime + Math.random();
    session.cookie = {
        expire: (new Date()).getTime() + EXPIRES
    };
    sessions[session.id] = session;
    return session;
};


app.post('/wjttest/pkg/query', urlencodedParser, function(req, res) {
/*    var id = req.cookie[key];
    if(!id){
        req.session = generate();
    }else{
        var session = sessions[id];
        if(session){
            req.session = session;
        } 
    }*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("req.session:-----" + JSON.stringify(req.session));
    console.log("req.sessionID---" + req.sessionID);
    console.log("验证请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({
        "path": "/wjttest/pkg/query"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("验证回调 datback......");
        console.log('data: ' + data);
//        res.end(data);
    });
    agentObjet.request();
        var queryRecord = monidata.getIdentify1(req.body);
        console.log(JSON.stringify(queryRecord));
        res.end(JSON.stringify(queryRecord));
});
app.post('/wjttest/mer/manag/show', urlencodedParser, function(req, res) {
/*    var id = req.cookie[key];
    if(!id){
        req.session = generate();
    }else{
        var session = sessions[id];
        if(session){
            req.session = session;
        } 
    }*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("req.session:-----" + JSON.stringify(req.session));
    console.log("req.sessionID---" + req.sessionID);
    console.log("验证请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({
        "path": "/wjttest/mer/manag/show"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("验证回调 datback......");
        console.log('data: ' + data);
//        res.end(data);
    });
    agentObjet.request();
        var queryRecord = monidata.getshowData(req.body);
        console.log(JSON.stringify(queryRecord));
        res.end(JSON.stringify(queryRecord));
});
app.post('/wjttest/main/home', urlencodedParser, function(req, res) {
/*    var id = req.cookie[key];
    if(!id){
        req.session = generate();
    }else{
        var session = sessions[id];
        if(session){
            req.session = session;
        } 
    }*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("req.session:-----" + JSON.stringify(req.session));
    console.log("req.sessionID---" + req.sessionID);
    console.log("验证请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({
        "path": "/wjttest/main/home"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("验证回调 datback......");
        console.log('data: ' + data);
//        res.end(data);
    });
    agentObjet.request();
        var queryRecord = monidata.gethomeData(req.body);
        console.log(JSON.stringify(queryRecord));
        res.end(JSON.stringify(queryRecord));
});

app.post('/wjttest/mer/manag/save', urlencodedParser, function(req, res) {
/*    var id = req.cookie[key];
    if(!id){
        req.session = generate();
    }else{
        var session = sessions[id];
        if(session){
            req.session = session;
        } 
    }*/
    // application/json  接口返回json数据
    // charset=utf-8 解决json数据中中文乱码
    res.writeHead(200, {
        "Content-Type": "application/json;charset=utf-8"
    });
    console.log("req.session:-----" + JSON.stringify(req.session));
    console.log("req.sessionID---" + req.sessionID);
    console.log("验证请求条件" + util.inspect(req.body));
    //   res.end(mndata.signIn);
    var agentObjet = dataAgent.getAgent({
        "path": "/wjttest/mer/manag/save"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("验证回调 datback......");
        console.log('data: ' + data);
//        res.end(data);
    });
    agentObjet.request();
        var queryRecord = monidata.getaddUser(req.body);
        console.log(JSON.stringify(queryRecord));
        res.end(JSON.stringify(queryRecord));
});



app.post('/wjttest/liveDec/SMSSendServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = vCodeAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/liveDec/GetCheckNumServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = getNumServletAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/liveDec/YouTuDetectServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = youtouAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/liveDec/KexinBrokenServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = kexinBrokenAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/liveDec/KexinBadrecordServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = kexinBarbrecordAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/liveDec/HengFengServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = hengFengAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});
app.post('/wjttest/LFQSendSMSServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = dataAgent.getAgent({
        path: "/wjttest/LFQSendSMSServlet"
    }, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});

app.post('/wjttest/FuLiBao/LFQSendSMSServlet', urlencodedParser, function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html;charset=utf-8'
    }); //设置response编码为utf-8
    console.log("取验证码条件" + util.inspect(req.body));
    var agentObjet = smsSeverAgent.getAgent({}, req.body);
    agentObjet.on("databack", function(data) {
        console.log("datback......");
        console.log('data: ' + data);
        res.end(data);
    });
    agentObjet.request();
});

var server = app.listen(8081, function() {

    var host = server.address().address;
    var port = server.address().port;

    console.log("应用实例，访问地址为 http://%s:%s", host, port)

});